﻿using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore;

namespace MinimalistFoodStreet.BackEnd.Repository.IRepository
{
    public interface IRepository<T> where T : class,new()
    {
        DbContext GetDbContext();
        int Add(T t);
        int Add(IEnumerable<T> ie);
        Task<int> AddAsync(T t);
        Task<int> AddAsync(IEnumerable<T> ie);
        int Update(T t);
        int Update(IEnumerable<T> ie);
        Task<int> UpdateAsync(T t);
        Task<int> UpdateAsync(IEnumerable<T> ie);
        int Delete(T t);
        int Delete(IEnumerable<T> ie);
        Task<int> DeleteAsync(T t);
        Task<int> DeleteAsync(IEnumerable<T> ie);
        int Save();
        Task<int> SaveAsync();
        DbSet<T> GetSet();
        IQueryable<T> Query();
        IQueryable<T> Query(Expression<Func<T,bool>> where);
        IQueryable<T> Query<TOrderKey>(Expression<Func<T,bool>> where,bool isAsc,Expression<Func<T, TOrderKey>>order);
        IQueryable<T> Pagination<TOrderKey>(Expression<Func<T, bool>> where, bool isAsc, Expression<Func<T, TOrderKey>> order,out int total, int page, int limit);
    }
}
